C Algorithms – Dijkstra’s Algorithm

This algorithm is a graph search algorithm that solves the shortest path problem for a graph. In the graph, the path between vertices has a cost or a length, so Dijkstra’s algorithm simply determines the path with the lowest cost between a vertex and another. The algorithm ends when the shortest path from a vertex to a destination vertex was discovered. How it works: 1) First thing to do is to set the distance value, which is 0 for the current node and infinity for the rest. 2) Set all the nodes as unvisited and initial node as current one;…